package org.cloud.automatic.queue.config;

import org.cloud.automatic.queue.service.ClientConfigService;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Objects;
import java.util.Properties;

/**
 * @Description: 补偿点信息获取
 * @Author: gangzhenga
 * @Date: 2021/7/28 11:30
 */
@Service("clientConfigService")
public class ClientConfigServiceImpl implements ClientConfigService {

	private static Hashtable hashtable = new Hashtable();

	@PostConstruct
	public void init() {
		InputStream resourceAsStream = ClientConfigServiceImpl.class.getClassLoader()
			.getResourceAsStream("serviceName.properties");

		if(Objects.isNull(resourceAsStream)) return;

		Properties properties = new Properties();
		try {
			properties.load(resourceAsStream);
			hashtable = properties;
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

    @Override
    public String getBeanNameFromConfig(String bizCode) {
		return hashtable.get(bizCode).toString();
    }

}
